package org.begincode.admin.service;

import org.begincode.core.mapper.UserManagerMapper;
import org.begincode.core.model.UserManager;
import org.springframework.stereotype.Service;
import org.springframework.util.DigestUtils;

import javax.annotation.Resource;

/**
 * Created by saber on 2016/7/4 0004.
 */
@Service("managerService")
public class ManagerService {
    @Resource
    private UserManagerMapper userManagerMapper;

    public UserManager checkLogin(String username, String password) {
        UserManager user = userManagerMapper.getUserByName(username);
        String md5Password = DigestUtils.md5DigestAsHex(password.getBytes());
        if (user != null && user.getPassword().equals(md5Password)) {
            return user;
        }
        return null;
    }


}
